
@call "L:\Products\LX_Library\settings.cmd"
set lxlib_VersionHigh=%ProductVersionHigh%
set lxlib_VersionMinor=%ProductVersionMinor%
set lxlib_VersionInternal=%ProductVersionInternal%
set lxlib_VersionBuild=%ProductVersionBuild%

@call "%~dp0..\..\settings.cmd"

rem command line parameters:
rem   <1 compiler type>
rem   <2 compiler version>
rem   <3 release type>

rem prepare environment variables
set idac_COMPILER_TYPE=%1
if %idac_COMPILER_TYPE% == Delphi (set idac_COMPILER_CHAR=d) else (set idac_COMPILER_CHAR=c)
set idac_COMPILER_VER=%2
set idac_RELEASE_TYPE=%3
if %idac_RELEASE_TYPE% == Trial (set idac_COMPILER_DEFINES=__TRIAL__) else (set idac_COMPILER_DEFINES=)

set lxlib_COMPILER_VER=%idac_COMPILER_VER%
set lxlib_RELEASE_TYPE=%idac_RELEASE_TYPE%
set lxlib_COMPILER_TYPE=%idac_COMPILER_TYPE%

set idac_COMPILER_STR=%idac_COMPILER_CHAR%%idac_COMPILER_VER%
if %idac_COMPILER_STR% == d9 (set idac_COMPILER_STR=d2005)
if %idac_COMPILER_STR% == d10 (set idac_COMPILER_STR=d2006)
if %idac_COMPILER_STR% == d11 (set idac_COMPILER_STR=d2007)
if %idac_COMPILER_STR% == c11 (set idac_COMPILER_STR=c2007)
set idac_ARCHIVE_FILENAME=idac_%ProductVersionHigh%.%ProductVersionMinor%.%ProductVersionInternal%.%ProductVersionBuild%%ProductVersionSuffix%_%idac_COMPILER_STR%
if %idac_RELEASE_TYPE% == Trial (set idac_ARCHIVE_FILENAME=%idac_ARCHIVE_FILENAME%_trial)
if %idac_RELEASE_TYPE% == Sources (set idac_ARCHIVE_FILENAME=%idac_ARCHIVE_FILENAME%_src)
set idac_SETUP_FILENAME=%idac_ARCHIVE_FILENAME%_setup

echo.
echo.
echo Make Win32 %idac_COMPILER_TYPE% %idac_COMPILER_VER% %idac_RELEASE_TYPE%
echo -----------------------------
echo.

echo   Cleanup product folder...
call "%BUILDDIR%\cleanup.cmd"

echo   Build product version...
call "%BUILDDIR%\build_%idac_COMPILER_CHAR%%idac_COMPILER_VER%.cmd" "%idac_COMPILER_DEFINES%"
if errorlevel 1 goto exit

echo   Make installation...
%INNOSETUP% "%~dp0.\idac.iss" > "%~dp0..\.make.log"
if errorlevel 1 goto error

rem if %idac_RELEASE_TYPE% == Trial goto done
echo   Archive installation...
if exist %idac_ARCHIVE_FILENAME% del /q %idac_ARCHIVE_FILENAME% > "%~dp0..\.make.log"
if errorlevel 1 goto exit
set idac_SETUP_FILENAME=%idac_SETUP_FILENAME%.exe
echo TempMode=Do you wish to continue installation of Informix Data Access Components?, Luxena Informix Data Access Components setup > "%~dp0.\script.txt"
echo Silent=1 >> "%~dp0.\script.txt"
echo Overwrite=1 >> "%~dp0.\script.txt"
echo Setup=%idac_SETUP_FILENAME% >> "%~dp0.\script.txt"
if %idac_RELEASE_TYPE% == Release (set idac_PASSWORD=-p%pswdIDAC%) else (if %idac_RELEASE_TYPE% == Sources (set idac_PASSWORD=-p%pswdIDACsrc%) else (set idac_PASSWORD=))
%WINRAR% a -m5 -md4096 -ep -s -sfx -z"%~dp0.\script.txt" %idac_PASSWORD% "%INSTALLDIR%\bin\%idac_ARCHIVE_FILENAME%" "%INSTALLDIR%\bin\%idac_SETUP_FILENAME%" > "%~dp0..\.make.log"
del /q "%~dp0.\script.txt" > nul
del /q "%INSTALLDIR%\bin\%idac_SETUP_FILENAME%" > nul
if errorlevel 1 goto error

:done
del /q "%~dp0..\.make.log"
echo.
echo -----------------------------
echo Make done.
goto exit

:error
type "%~dp0..\.make.log"
pause

:exit
cd %~dp0..\